class SubresidsController < ApplicationController
   before_filter(:get_resident)

  def create
    # Create a subtourist object that has
    # been instantiated with attributes
    # and linked to the tourist object
    @subresid = @resident.subresids.build(params[:subresid])
    @subresid.img = session[:url]
    if @subresid.save
      flash[:notice] = 'subtourist was successfully created.'
      respond_to do |format|
        format.html { redirect_to resident_url(@resident) }
        format.xml  { render :xml => @subresid,
          :status => :created, :location => @resident }
      end
    else
      flash[:notice] = 'subresid was not created.'
      respond_to do |format|
        format.html { redirect_to resident_url(@resident) }
        format.xml  { render :xml => @subresid.errors,
          :status => :unprocessable_entity }
      end
    end
  end

private

  def get_resident
     @resident = Resident.find(params[:resident_id])
  end

end
